'''
Created on Oct 25, 2010

@author: Tom Smith
'''
from TwainControl import TwainBase
import twain
import Tkinter
import os
import time
import inspect
F=Tkinter.Frame()
window = F.winfo_id()






for i in range(1):
    scanner = TwainBase()
    scanner.OpenScanner(window, "CanoScan FB630U/FB636U")
    scanner.SD.SetCapability(twain.ICAP_YRESOLUTION, twain.TWTY_FIX32, 600.0) 
    scanner.SD.SetCapability(twain.ICAP_XRESOLUTION, twain.TWTY_FIX32, 600.0)
    print scanner.SD.GetCapability(twain.ICAP_CONTRAST)
    print scanner.SD.GetCapability(twain.ICAP_PIXELTYPE)
    scanner.SD.SetCapability(twain.ICAP_PIXELTYPE, twain.TWTY_UINT16, twain.TWPT_GRAY)
    scanner.AcquireByFile()
    watch = ''
    while(watch == ''):
        watch = scanner.PollForImage()
        time.sleep(5)
    t = time.time()
    os.rename('TWAIN.tmp', '%s.tiff' % t)
    time.sleep(5)
